package com.tao.mvpbaselibrary.basic.rxbus;

import io.reactivex.functions.Consumer;

public abstract class BaseRxubsConsumer<T, E extends Throwable> {
    private Consumer<T> next;
    private Consumer error;

    public BaseRxubsConsumer() {
        next = new Consumer<T>() {
            @Override
            public void accept(T data) throws Exception {
                onAccept(data);
            }
        };
        error = new Consumer<E>() {
            @Override
            public void accept(E e) throws Exception {
                onError(e);
            }
        };
    }

    public <E extends Throwable> Consumer<? super E> error() {
        return error;
    }

    public Consumer<? super T> next() {
        return next;
    }

    public abstract void onAccept(T t);

    public void onError(E e) {

    }

}
